package gui.gui2d.highLevelPanels.utils;

import gui.gui2d.TestAnimatedPane.Animate;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class SelecterExitInfoPanel extends JPanel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	String carattere = "TimesRoman";
	int plain = Font.ITALIC;
	int dimensioni = 40;
	Font font = new Font(carattere, plain, dimensioni);
	Font font1 = new Font(carattere, plain, 30);
	JButton ok = new JButton("Si");
	JButton no= new JButton("No"); 


	Rectangle from = new Rectangle(400,0 , 350, 120);
	Rectangle to = new Rectangle(0,0 , 350, 120);
	private JPanel panel;

	public SelecterExitInfoPanel() {
		setLayout(null);
		panel = new JPanel();
		panel.setBackground(new Color(50,23,23,100));
		panel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		panel.repaint();
	}

	public void addPanel(){
		panel.removeAll();
		panel.revalidate();
		panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
		JLabel jl = new JLabel("Sei sicuro?");
		ok.setFont(font1);
		no.setFont(font1);
		ok.setPreferredSize(new Dimension(90,40));
		no.setPreferredSize(new Dimension(90,40));
		JPanel buttonsPanel=  new JPanel();
		buttonsPanel.setOpaque(false);
		buttonsPanel.setLayout(new FlowLayout());
		buttonsPanel.add(ok);
		buttonsPanel.add(no);
		jl.setFont(font);
		jl.setForeground(Color.white);
		panel.add(jl);
		panel.add(buttonsPanel);
		
		Animate animate = new Animate(panel, from, to);
		animate.start();
		
		add(panel);
		no.addMouseListener(new MouseListener() {

			@Override
			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void mouseExited(MouseEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void mouseEntered(MouseEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void mouseClicked(MouseEvent arg0) {
				// TODO Auto-generated method stub
				removePanel();
			}
		});
	}



	public void addListener(MouseListener ml){
		ok.addMouseListener(ml);

	}


	public void removePanel(){
		Animate animate = new Animate(panel, to, from);
		animate.start();
	}



	@Override
	public Dimension getPreferredSize() {
		return new Dimension(200, 200);
	}
}
